package com.ibuu.config;

import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

@Component
public class DataSourceInitializer {

    @Autowired
    private DataSource dataSource;

    @PostConstruct
    public void warmUp() {
        try (Connection conn = dataSource.getConnection()) {
            // Test connection
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}